package com.higold.cloud.ui.adapter

import android.text.TextPaint
import android.text.style.ClickableSpan
import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.higold.cloud.R
import com.higold.cloud.mvp.model.bean.regionalDetail.Data
import com.higold.cloud.utils.AppUtils
import com.higold.cloud.view.UpdataAPPProgressBar

/**
 *    author : lxz
 *    date   : 2019/8/19 15:48
 *    desc   :
 */

class ManagerListAdapter(data: ArrayList<Data>) : BaseQuickAdapter<Data, BaseViewHolder>(R.layout.item_manager_detail, data) {

    override fun convert(helper: BaseViewHolder, item: Data) {
//        (helper.getView<View>(R.id.tweetText) as TextView).text = SpannableStringUtils.getBuilder(msg).append("landscapes and nedes").setClickSpan(clickableSpan).create()
//        (helper.getView<View>(R.id.tweetText) as TextView).movementMethod = LinkMovementMethod.getInstance()
        helper.setText(R.id.tv_month, item.month.toString() + "月")
                .setText(R.id.tv_goal, AppUtils.changeFloatToString(item.amount) + "w / "
                        + AppUtils.changeFloatToString(item.missionAmount) + "w本月")
                .setText(R.id.tv_percent, AppUtils.changeFloatToString((item.amount / item.missionAmount) * 100) + "%")

        val progress = (helper.getView<View>(R.id.pb_moth) as UpdataAPPProgressBar)
        progress.progress = ((item.amount / item.missionAmount) * 100).toFloat()
        progress.duration = 1500
        progress.startAnim()
    }

    internal var clickableSpan: ClickableSpan = object : ClickableSpan() {
        override fun onClick(widget: View) {

        }

        override fun updateDrawState(ds: TextPaint) {
//            ds.color = Utils.getContext().getResources().getColor(R.color.clickspan_color)
//            ds.isUnderlineText = true
        }

    }


}
